package com.ustb.springboot.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ustb.springboot.entity.QuestionCheckboxEntity;
import com.ustb.springboot.service.QuestionCheckboxService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ustb.springboot.entity.AnswerCheckboxEntity;
import com.ustb.springboot.service.AnswerCheckboxService;
import com.ustb.springboot.common.utils.R;

import javax.servlet.http.HttpServletRequest;


/**
 * @author pyn
 * @date 2022-05-17 11:26:55
 */
@RestController
@RequestMapping("answercheckbox")
public class AnswerCheckboxController {
    @Autowired
    private AnswerCheckboxService answerCheckboxService;
    @Autowired
    private QuestionCheckboxService questionCheckboxService;

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("answercheckbox:save")
    public R save(HttpServletRequest request, @RequestBody Map<String, Object> body) {
        return answerCheckboxService.save(request, body);
    }


    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("answercheckbox:delete")
    public R delete(@RequestBody Map<String, Object> body) {
        return answerCheckboxService.delete(body);
    }

    @RequestMapping("/summerize")
    @RequiresPermissions("answercheckbox:summerize")
    public R summerize(@RequestBody Map<String, Object> body){
        //System.out.println(body.get("question_id").toString());
        Map<String , Object> summerize= new HashMap<>();
        summerize = answerCheckboxService.summerizeCheckboxMessage(body);
        if (null == summerize)
            return R.ok(2000, "暂无信息!");
        else
            return R.ok(20000, "查询成功!").put("summerize_checkbox", summerize);
    }
}
